//
//  ZQNavigationController.m
//  柳州微博
//
//  Created by Apple_Lzzy40 on 16/9/19.
//  Copyright © 2016年 Apple_Lzzy40. All rights reserved.
//

#import "ZQNavigationController.h"

@implementation ZQNavigationController
+(void)initialize
{
    //设置导航的主题样式
    UIBarButtonItem *item=[UIBarButtonItem appearance];
    
    
    
    //定义可变字典
    NSMutableDictionary *textAttributes=[NSMutableDictionary dictionary];
    
    //设置字体大小
    textAttributes[NSFontAttributeName]=[UIFont systemFontOfSize:13];
    
    //设置字体颜色
//    textAttributes[NSForegroundColorAttributeName]=[UIColor purpleColor];
    
    //设置常态
    [item setTitleTextAttributes:textAttributes forState:UIControlStateNormal];
    
    //定义可变字典
    NSMutableDictionary *disbleTextAttributes=[NSMutableDictionary dictionary];
    
    //设置字体大小
    disbleTextAttributes[NSFontAttributeName]=[UIFont systemFontOfSize:13];
    
    //设置字体颜色
    disbleTextAttributes[NSForegroundColorAttributeName]=[UIColor purpleColor];
    
    //设置禁用状态
    [item setTitleTextAttributes:disbleTextAttributes forState:UIControlStateDisabled];

}



-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
//    NSLog(@"%@ ",viewController);
    if (self.viewControllers.count>0) {
        //隐藏下栏
        viewController.hidesBottomBarWhenPushed = YES;
        
//        viewController.navigationItem.leftBarButtonItem=[self setBtnWithAction:@selector(back) iamge:@"navigationbar_back" highLiightedImage:@"navigationbar_back_highlighted"];
//        viewController.navigationItem.rightBarButtonItem=[self setBtnWithAction:@selector(backRight) iamge:@"navigationbar_more" highLiightedImage:@"navigationbar_more_highlighted"];
        //导航栏左上角按钮
        viewController.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(back) iamge:@"navigationbar_back" highLiightedImage:@"navigationbar_back_highlighted" ];
         //导航栏右上角按钮
        viewController.navigationItem.rightBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(backRight) iamge:@"navigationbar_more" highLiightedImage:@"navigationbar_more_highlighted"];
        
    }
    //是否显示动画
    [super pushViewController:viewController animated:YES];
    }



-(UIBarButtonItem *)setBtnWithAction:(SEL)action  iamge:(NSString *)iamge  highLiightedImage:(NSString *)highLiightedImage
{
    //自定义按钮
    UIButton *Btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    //响应事件
    [Btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    //设置常态图片
    [Btn setBackgroundImage:[UIImage imageNamed:iamge] forState:UIControlStateNormal];
    
    //设置高亮图片
    [Btn setBackgroundImage:[UIImage imageNamed:highLiightedImage] forState:UIControlStateHighlighted];
    
    Btn.size =Btn.currentBackgroundImage.size;
    
    return [[UIBarButtonItem alloc]initWithCustomView:Btn];
  
}


-(void)back
{
    [self popViewControllerAnimated:YES];
}

-(void)backRight
{
    [self popToRootViewControllerAnimated:YES];
}

@end
